<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>综合应用ECharts</title>
    <script type="text/javascript" src="../../frame/echarts/echarts.min.js"></script>
    <style>
        div{
            margin:0;
            padding:0;
            display: inline-block;
        }
    </style>
</head>
<body>
<div id="bar" style="width: 100%;height:500px;"></div>
<script>
    bar();
    function bar() {
        var myChart = echarts.init(document.getElementById("bar"));
        // 指定图表的配置项和数据
        var data = new Array();
        var data1 = new Array();
        var data2 = new Array();
        var num = new Array();
        for(var i = 1;i < 1000; i++) {
            data.push(Math.ceil(Math.random()*100));
            data1.push(Math.ceil(Math.random()*90));
            data2.push(Math.ceil(Math.random()*80));
            num.push(i);
        }
        var option = {
            title: {
                text: 'ECharts 矩形图',
                subtext: '来自时光演示网',
                sublink: 'http://demo.sgfoot.com',
                left: 'center',
                textStyle: {
                    color: '#2E3299'
                }
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    crossStyle: {
                        color: '#999'
                    }
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    show: true,
                    start: 94,
                    end: 100,
                    handleSize: 40
                },
                {
                    type: 'inside',
                    start: 94,
                    end: 100
                },
                {
                    type: 'slider',
                    show: true,
                    yAxisIndex: 0,
                    filterMode: 'empty',
                    width: 12,
                    height: '70%',
                    handleSize: 8,
                    showDataShadow: false,
                    left: '93%'
                }
            ],
            legend: {
                orient: 'vertical',
                left:'right',
                data:['浏览量', '销量', 'view'],
                textStyle: {
                    color: '#000'
                }
            },
            xAxis: {
                data: num
            },
            yAxis: {},
            series: [{
                name: '浏览量',
                type: 'line',
                data: data,
                label: {
                    normal: {
                        show: true,
                        position: 'top'
                    }
                }
            },{
                name: '销量',
                type: 'bar',
                data: data1,
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                }
            },{
                name: 'view',
                type: 'bar',
                data: data2,
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                }
            }]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }
</script>
</body>
</html>